home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / bin / scsi_satl < prev    next >
Text File  |  2008-05-03  |  4KB  |  129 lines

  1. #!/bin/bash
  2. # scsi_satl
  3. #
  4. # Script to test compliance of SCSI commands on a SCSI to ATA
  5. # Transaltion (SAT) Layer (SATL). This scripts was compiled using
  6. # sat-r09.pdf found at www.t10.org .
  7. # The vintage is SPC-3 and SPC-4 (see www.t10.org).
  8. #
  9. # Coverage:
  10. # Command                SATL notes
  11. # -------------------------------------------------------
  12. # INQUIRY (standard)
  13. # INQUIRY (VPD: 0)
  14. # INQUIRY (VPD: 0x83)    Device identification VPD page
  15. # INQUIRY (VPD: 0x89)    ATA Information VPD page
  16. # REPORT LUNS            SPC-3, SPC-4 (hardly mentioned in sat-r08c)
  17. # TEST UNIT READY        
  18. # REQUEST SENSE          
  19. # SEND DIAGNOSTIC        default self test        
  20. # MODE SENSE(10)         draft unclear which mode pages, so ask for all
  21. # ATA PASS THROUGH(16)   send IDENTIFY DEVICE command. Assume non-packet
  22. #                        device, if packet device add "-p" option
  23. #
  24. # This script uses utilities from sg3_utils package (version
  25. # 1.22 or later) and sdparm (version 0.99 or later)
  26. #
  27. # Douglas Gilbert 20070317
  28.  
  29.  
  30. quiet=0
  31. log=0
  32.  
  33. file_err=0
  34. inv_opcode=0
  35. illeg_req=0
  36. not_ready=0
  37. medium=0
  38. other_err=0
  39. recovered=0
  40. sanity=0
  41. syntax=0
  42. timeout=0
  43. unit_attention=0
  44. aborted_command=0
  45.  
  46. total_err=0
  47.  
  48. usage()
  49. {
  50.   echo "Usage: scsi_satl [-h] [-L] [-q] <device>"
  51.   echo "  where:  -h, --help       print usage message"
  52.   echo "          -L, --log        append stderr to 'scsi_satl.err'"
  53.   echo "          -q, --quiet      suppress some output"
  54.   echo ""
  55.   echo "Check <device> for SCSI to ATA Translation Layer (SATL) support"
  56. }
  57.  
  58. if (( $# < 1 ))
  59.   then
  60.     usage
  61.     exit 1
  62. fi 
  63.  
  64. # opt=$1
  65. # echo ${opt##-*}
  66.  
  67. opt="$1"
  68. while test ! -z "$opt" -a -z "${opt##-*}"; do
  69.   opt=${opt#-}
  70.   case "$opt" in
  71.     h|-help) usage ; exit 1 ;;
  72.     L|-log) let log=$log+1 ;;
  73.     q|-quiet) let quiet=$quiet+1 ;;
  74.     *) echo "Unknown option: -$opt " ; exit 1 ;;
  75.   esac
  76.   shift
  77.   opt="$1"
  78. done
  79.  
  80. for command in "sg_inq" "sg_vpd" "sg_vpd -p di" "sg_vpd -p ai" "sg_luns" \
  81.                "sg_turs" "sg_requests -s" "sg_senddiag -t" "sg_modes -a" \
  82.                "sg_sat_identify"
  83. do
  84.   if [ $quiet -eq 0 ]
  85.     then echo "$command" $1
  86.   fi
  87.  
  88.   if [ $log -eq 0 ]
  89.   then
  90.     $command $1 > /dev/null 2>> /dev/null
  91.   else
  92.     $command $1 > /dev/null 2>> scsi_satl.err
  93.   fi
  94.   res=$?
  95.   case "$res" in
  96.     0) ;;
  97.     1) echo "  syntax error" ; let syntax=$syntax+1 ;;
  98.     2) echo "  not ready" ; let not_ready=$not_ready+1 ;;
  99.     3) echo "  medium error" ; let medium=$medium+1 ;;
  100.     5) echo "  illegal request, general" ; let illeg_req=$illeg_req+1 ;;
  101.     6) echo "  unit attention" ; let unit_attention=$unit_attention+1 ;;
  102.     9) echo "  illegal request, invalid opcode" ; let inv_opcode=$inv_opcode+1 ;;
  103.     11) echo "  aborted command" ; let aborted_command=$aborted_command+1 ;;
  104.     15) echo "  file error with $1 " ; let file_err=$file_err+1 ;;
  105.     20) echo "  no sense" ; let other_err=$other_err+1 ;;
  106.     21) echo "  recovered error" ; let recovered_err=$recovered_err+1 ;;
  107.     33) echo "  timeout" ; let timeout=$timeout+1 ;;
  108.     97) echo "  response fails sanity" ; let sanity=$sanity+1 ;;
  109.     98) echo "  other SCSI error" ; let other_err=$other_err+1 ;;
  110.     99) echo "  other error" ; let other_err=$other_err+1 ;;
  111.     *) echo "  unknown exit status for sg_inq: $res" ; let other_err=$other_err+1 ;;
  112.   esac
  113. done
  114.  
  115. echo ""
  116. let total_bad_err=$file_err+$inv_opcode+$illeg_req+$medium+$aborted_command
  117. let total_bad_err+=$other_err+$recovered+$sanity+$syntax+$timeout
  118.  
  119. let total_allow_err=$not_ready+$unit_attention
  120.  
  121.   echo "total number of bad errors: $total_bad_err "
  122.  
  123. if [ $total_allow_err -gt 0 ]
  124.   then
  125.   echo "total number of allowable errors: $total_allow_err "
  126. fi
  127.  
  128. exit $total_bad_err
  129.